#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include "dominion/dominion.h"
#include "dominion/dominion_helpers.h"
#include "dominion/rngs.h"
#include "dominion/interface.h"

/* testing isGameOver() */

int isGameOver(struct gameState *state);

int main(int argc, char * argv[])
{
	/*modified from the initialization in the provided testUpdateCoins.c file */
    int seed = 1000;  
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
	int r;
	
	/* test one -- to see if gameover is reached when there are no provinces left */
	struct gameState test_one;
    memset(&test_one, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_one); // initialize a new game

	test_one.supplyCount[province] = 0;
	if (isGameOver(&test_one))
		printf("isGameOver(): PASS when testing to see if game is over when no province cards left.\n");
	else
		printf("isGameOver(): FAIL when testing to see if game is over when no province cards left.\n");
	
	/* test two -- to see if gameover is reached when three cards have a stack of 0 */
	struct gameState test_two;
    memset(&test_two, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_two); // initialize a new game
	
	test_two.supplyCount[feast] = 0;
	test_two.supplyCount[gardens] = 0;
	test_two.supplyCount[mine] = 0;
	
	if (isGameOver(&test_two))
		printf("isGameOver(): PASS when testing to see if game is over when 3 cards have a stack of 0.\n");
	else
		printf("isGameOver(): FAIL when testing to see if game is over when 3 cards have a stack of 0.\n");
		
	/* test three -- to see if gameover is NOT reached when only two cards have a stack of 0 */
	struct gameState test_three;
    memset(&test_three, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_three); // initialize a new game
	
	test_three.supplyCount[council_room] = 0;
	test_three.supplyCount[smithy] = 0;
	
	if (isGameOver(&test_three) == 0)
		printf("isGameOver(): PASS when testing to see if game is NOT over when 2 cards have a stack of 0.\n");
	else
		printf("isGameOver(): FAIL when testing to see if game is NOT over when 2 cards have a stack of 0.\n");
		
	/* test four -- boundary case to see if gameover is NOT reached when 3 cards not available in this game are 0.*/
	struct gameState test_four;
    memset(&test_four, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &test_four); // initialize a new game
	
	test_four.supplyCount[embargo] = 0;
	test_four.supplyCount[outpost] = 0;
	test_four.supplyCount[salvager] = 0;
	
	if (isGameOver(&test_four) == 0)
		printf("isGameOver(): PASS when testing to see if game is NOT over when 3 cards NOT in the deck have a stack of 0.\n");
	else
		printf("isGameOver(): FAIL when testing to see if game is NOT over when 3 cards NOT in the deck have a stack of 0.\n");
		
	
	return 0;
	
}